1. Field of the Invention
The present invention is related generally to a data processing system and in particular to a method and apparatus for behavior profiles. More particularly, the present invention is directed to a computer implemented method, apparatus, and computer usable program code for comparison of behavior profiles collected during adaptive optimization cycles.
2. Description of the Related Art
A control flow graph is a representation of all paths that may be traversed during execution of a program. A basic block forms each node in a control flow graph. A basic block is a group of machine instructions that are executed together. A basic block has a single entry point and a single exit point. A basic block typically only includes branch instructions at the end of the basic block. A branch instruction may also be referred to as a jump instruction. In other words, a basic block is a piece of code in which every instruction in the basic block code is executed in a sequential order without any branches in the code. Control flow graphs are typically used by compiler optimizations and program performance analysis tools. The directed edges in the control flow graph represent the branch instructions.
Performance analysis, which is also referred to as profiling, is a tool for measuring and describing a program's behavior using information collected during execution of the program. A common way to represent program behavior is via a profile. The output of a performance analysis is a series of recorded events or sequence of basic blocks that execute one after another, referred to as a trace. The events are described in a summary that is frequently referred to as a profile. The profile attaches information describing program behavior during runtime to elements in a control flow graph representing the program execution.
The profile generally includes information describing program behavior such as, but not limited to, execution frequency of each basic block, duration of function calls, frequency of function calls, the number of cache misses in each natural loop, and so forth. Profiling can also describe program behavior features that are not related to performance, such as, without limitation, instruction execution frequency.
In one solution, dynamic optimizers optimize a code portion, such as, without limitation, methods and traces, when they become “hot.” A hot method or hot trace is a method or trace that is frequently traversed or executed. Behavior profiles are used to determine which parts of a program to optimize. Optimizations of program code can result in improved execution speed, more efficient memory usage, and/or any other domains for improving performance of the code during execution.
Optimizers typically optimize frequently executed code, such as, but not limited to, hot loops or hot traces, only once during the optimization process or only one per optimization level. These optimizers do not adapt to changes in profile information and execution paths occurring during execution of the program code. However, many optimizations like inlining, specialization, and code reorder that might benefit from adaptive optimization that is profile directed, such as adaptive code optimization.
In adaptive optimization, an optimization cycle adapts the program code to the current behavior of the program code. The domain in adaptive optimization is program compilation or program re-compilation. The behavior profile based adaptive code optimization aims at characterizing the program behavior using profiles, optimizing the code to improve performance, and detecting significant dynamic changes in the program behavior to trigger re-optimization of the optimized code. This cycle of performance analysis and dynamic optimization during program execution occurs in a continuous process that monitors the application occasionally and re-adapts the application when a significant change in program behavior is detected. However, adaptive code optimizations change the program code of the optimized applications and make the comparison of currently available behavior profiles for different optimization cycles of the same program code difficult or impossible.